package com.furioussnails.sourcecodeanalysis.sqlsession;

import com.furioussnails.sourcecodeanalysis.config.XMLConfigBuilder;
import com.furioussnails.sourcecodeanalysis.pojo.Configuration;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory builder(InputStream inputStream) throws Exception{

        //1.使用dom4j解析配置文件,将解析出来的内容封装到Configuration
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        //2.创建SqlSessionFactory对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return defaultSqlSessionFactory;

    }
}
